<template>
	<view class="">
		<div v-if="gjp">
			<u-skeleton :loading="true" :animate="true" rows="7"  rowsHeight="100"></u-skeleton>
		</div>
		
		<div class="zwxqPage" v-else>
			<div class="container">
				<div class="item">
					<h3>{{ zw.zwmc }}</h3>
					<div class="tags">
						<div >
							<u-tag :text="2023" type="error" plain plainFill size="mini"></u-tag>
						</div>
						<div>
							<u-tag :text="zw.zwxz" type="error" plain plainFill size="mini"></u-tag>
						</div>
						<div>
							<u-tag :text="zw.zy == '不限' ? '不限专业' : '限专业' " type="error" plain plainFill size="mini"></u-tag>
						</div>
						<div v-if="zw.xb">
							<u-tag :text="zw.xb == '不限' ? '不限性别' : zw.xb " type="error" plain plainFill size="mini"></u-tag>
						</div>
					</div>
					<ul>
						<li><span>招录人数</span> <i>{{ zw.zkrs }}</i></li>
						<li><span>招考单位</span> <i>{{ zw.bmmc }}</i></li>
					</ul>
				</div>
				<div class="item" v-if="year >1000">
					<h3>报名数据</h3>
					<div class="flexBox">
						<div class="bmrs_color">{{ zw.bmrsbl }}<span>补录报名人数</span></div>
						<div class="bmrs_color">{{ zw.bmrsbl ? showJzb(zw.bmrsbl,zw.zkrs) : 0 }}<span>竞争比</span></div>
					</div>
					
					<p class="warningText">* 数据来源网络（白雪面试整理发布）</p>
				</div>
				<div class="item">
					<h3>分数详情</h3>
					<div class="">
						<div class="bmrs_color">
							<ul>
								<li>{{zw.bsfs}}<span>笔试分数</span></li>
								<li>{{zw.msfs}}<span>面试分数</span></li>
								<li>{{zw.zfs}}<span>总分数</span></li>
							</ul>
						</div>
					</div>
					<p class="warningText">* 数据来源2023年省考数据（白雪面试整理发布）</p>
				</div>
				<div class="item">
					<h3>职位信息</h3>
					<ul>
						<li><span>职位名称:</span>{{zw.zwmc}}</li>
						<li><span>职位代码:</span>{{zw.zwdm}}</li>
						<li><span>招考人数:</span>{{zw.zkrs}}</li>
						<li><span>职位性质:</span>{{zw.zwxz}}</li>
					</ul>
				</div>
				<div class="item">
					<h3>单位信息</h3>
					<ul>
						<li><span>地区:</span>{{zw.city}}</li>
						<li><span>所属系统:</span>{{zw.xt}}</li>
						<li><span>部门名称:</span>{{zw.bmmc}}</li>
						<li><span>部门代码:</span>{{zw.bmdm}}</li>
						<li><span>用人处（科）室:</span>{{zw.yrcs}}</li>
					</ul>
				</div>
				<div class="item">
					<h3>报考条件</h3>
					<ul>
						<li><span>招考对象:</span>{{zw.zkdx}}</li>
						<li><span>学历:</span>{{zw.xl}}</li>
						<li><span>专业:</span>{{zw.zy}}</li>
						<li><span>工作经历:</span>{{zw.gzjl}}</li>
						<li><span>政治面貌:</span>{{zw.zzmm}}</li>
						<li><span>岗位最低服务年限:</span>{{zw.fwnx}}</li>
					</ul>
				</div>
				<div class="item">
					<h3>其他信息</h3>
					<ul>
						<li><span>备注:</span>{{zw.bz}}</li>
					</ul>
				</div>
			</div>
			
		</div>
		<u-toast ref="uToast"></u-toast>
	</view>
</template>

<script>
	import {
		mapActions
	} from 'vuex';
	const db = wx.cloud.database();
	export default {
		data() {
			return {
				gjp: true,
				year: "2022",
				wyz: "",
				zwLink: "https://hljhd.offcn.com/lynn/2023blzw.js",
				zw: {},
				fsList: []
			};
		},
		onShow() {},
		onPullDownRefresh() {
			console.log('refresh');
			setTimeout(function() {
				uni.stopPullDownRefresh();
			}, 1000);
		},
		onPageScroll(e) {
			let that = this;
			that.scrollTop = e.scrollTop;
		},
		onLoad(options) {
			if (!options) {} else {
				this.wyz = options.wyz
				
			}
		},
		computed: {
			
		},
		mounted() {
			this.getAllZw()
		},
		watch: {},
		created() {
			let that = this;
			
		},
		methods: {
			
			getAllZw(){
				let that = this
				let p = that.personSearch
				
				uni.request({
					url: that.zwLink,
					method: 'get',
					dataType: 'text',
					data: {
						sstimes: new Date()
					},
					success: function(res) {
						var resjson = JSON.parse(res.data);
						that.filterZw(resjson)
					}
				});
			},
			filterZw(zw){
				let that = this
				let fzw = zw.filter(item => item.wyz == that.wyz)
				that.zw = fzw[0]
				that.gjp = false
				that.getScore()
			},
			showToast(type, info) {
				this.$refs.uToast.show({
					type: type,
					icon: false,
					title: '失败主题',
					message: info,
				})
			},
			open(e) {
				let that = this
				// console.log(e)
			},
			imgView(imgUrl) {
				wx.previewImage({
					urls: [imgUrl], //需要预览的图片http链接列表，注意是数组
					current: '', // 当前显示图片的http链接，默认是第一个
					success: function(res) {},
					fail: function(res) {},
					complete: function(res) {}
				});
			},
			
			showJzb(jfrs,zkrs){
				let jzb = jfrs / zkrs
				jzb % 1 === 0 ? jzb = jzb : jzb = jzb.toFixed(2)
				return jzb
			},
			getScore(){
				let that = this
				if(that.year >= 2023){
					db.collection('sk_fenshu_2023').where({
						wyz: that.zw.wyz
					})
					.get({
						success: function(res) {
							if (res.data.length > 0) {
								console.log(res)
								that.fsList = res.data
							}else{
								that.fsList = []
							}
						}
					})
				}
				
			}
		},
		components: {}
	};
</script>

<style lang="scss">
	@import url(./index.css);
</style>
